package week5;

public class Q2 {


    public static boolean isPrime(int num){
        if (num<=1){
            return false;
        }
        for(int i=2;i*i<=num;i++){
            if(num%i==0){
                return false;
            }

        }
        return true;
    }
    public static void main(String[] args) {
        for(int i=2;i<=1000;i++){
            if(i==2){
                System.out.println(i + " ");
                continue;

            }
            for (int j=2;j<=i;j++){
                if(i%j==0){
                    break;
                }else if(j==i-1){
                    System.out.println(i+ " ");
                }
            }
        }
        System.out.println();
        for(int j=1;j<=1000;j++){
            if(isPrime(j)){
                System.out.println(j+ " ");
            }
        }
    }
}
